/**
 * Created by zheng on 2018/12/15.
 */

import {LOGOUT, LOGIN, LOGIN_SUCCESS, LOGIN_FAIL} from '@/constants/ActionTypes'

const initialState = {
	id: '',
	username: ''
}

const user = (state = initialState, action) => {
	switch (action.type) {
		case LOGOUT:
			return {
				id: '',
				username: ''
			}
		case LOGIN_SUCCESS:
			return loginSuccess(state, action)
		default:
			return state
	}
}

const loginSuccess = (state, action) => {
	debugger;
	return {
		...action.payload.data
	}
}

export default user